package com.lpf.iterator;

// 客户端代码
public class IteratorPatternDemo {
    public static void main(String[] args) {
        // 创建书架并添加书籍
        BookShelf bookShelf = new BookShelf(5);
        bookShelf.appendBook("Effective Java");
        bookShelf.appendBook("Clean Code");
        bookShelf.appendBook("Design Patterns");

        // 使用迭代器遍历书架
        Iterator iterator = bookShelf.createIterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }
}